#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
#include <string.h>
#include <sys/wait.h>
#include <stdio.h>


int main(int argc, char **argv)
{
	char *p;
	int fd,len;	
		
	fd = open("mymap",O_RDONLY);
	printf("%d\n",fd);		

	p = (char *)mmap(NULL,BUFSIZ,PROT_READ,MAP_SHARED,fd,0);
	close(fd);//close is crucial		

	while(1)
	{
		write(STDOUT_FILENO, p, BUFSIZ);
		//printf("recv: %s", p);
		sleep(1);
		//write(STDOUT_FILENO, p, len*sizeof(char));
	}
	munmap(p,len);
}
